<template>
  <div>
      <!-- 头部部分 -->
      <header class="header">
      <h1>todos</h1>
      <input class="new-todo" placeholder="请输入任务名称" 
      v-model.trim="inputTag"
      @keydown.enter="add"
      autofocus />
    </header>

  </div>
</template>

<script>
export default {
  name: 'PracticeTodoHeader',
 
  data() {
    return {
      inputTag:''
    };
  },


  methods: {
    add() {
      if(this.inputTag === '') return alert('请输入')
      this.$emit('addTask',this.inputTag)
      this.inputTag=''
      
    }
  },
};
</script>

<style lang="scss" scoped>

</style>